//
//  YQTalkDetailViewController.m
//  EPA--1
//
//  Created by lanou3g on 16/4/23.
//  Copyright © 2016年 刘永庆. All rights reserved.
//

#import "YQTalkDetailViewController.h"

@interface YQTalkDetailViewController ()
@property (nonatomic, strong) UIWebView *webView;
@property (nonatomic, strong) NSString *htmlStr;
@end

@implementation YQTalkDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.htmlStr = [NSString string];
    self.webView = [[UIWebView alloc]initWithFrame:self.view.frame];
    [self.view addSubview:self.webView];
    [self loadData];
}
- (void)loadData
{
    [YQNetWorkRequestManager requestURL:[NSURL URLWithString:TOPICINFO_URL] method:YQ_POST params:@{@"contentid":self.contentid,@"client":@"1",@"deviceid":@"63A94D37-33F9-40FF-9EBB-481182338873",@"auth":@"Wc06FCrkoq1DCMVzGMTikDJxQ8bm3Mrm2NpT9qWjwzcWP23tBKQx1c4P0",@"version":@"3.0.2"} result:^(NSData *data, NSURLResponse *response, NSError *error) {
        if (data) {
            NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
            NSDictionary *dataDict = dict[@"data"];
            dispatch_async(dispatch_get_main_queue(), ^{
            NSString *str = dataDict[@"postsinfo"][@"html"];
            self.htmlStr = [NSString stringWithFormat:@"<head><style>img{max-width:320px !important;}</style></head>%@",str];
                
            [self.webView loadHTMLString:self.htmlStr baseURL:nil];
//                [self.webView sizeToFit];
//                self.webView.scalesPageToFit = NO;
            });
        }
    }];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
